import {request, writeLog} from "../libs/core.js"
export default {
  namespaced: true,  //多出的一行
  state: {
  	user: {},
    module: []
  },
  mutations: {
    initSet(state, datas) {
        for (let keys in datas) {
            state[keys] = datas[keys];
        }
    }
  },
  getters: {
  	user: state => {
  		return state.user;
  	}
  },
  actions: {
    async loadModule(context) {
		try {
            const data = await request({url:'/api/core/module/tree', method:'post'});
            if (data && data.code == 0 && data.datas.tree) {
                context.commit("initSet", {module:data.datas.tree});
            }
		} catch(e) {
            writeLog(0, e);
		}
		return false;
    }
  }
}
